//
//  FunctionKeyBoard.m
//  79环信
//
//  Created by 刘恒槟 on 15/8/4.
//  Copyright (c) 2015年 刘恒槟. All rights reserved.
//

#import "FunctionKeyBoard.h"

@interface FunctionKeyBoard ()

@end

@implementation FunctionKeyBoard

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self functionKBitem];
        
    }
    return self;
}

-(void)functionKBitem{
    
    UIImage * photo = [[UIImage imageNamed:@"chatBar_colorMore_photo"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    UIImage * camera = [[UIImage imageNamed:@"chatBar_colorMore_camera"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
//    UIImage * video = [[UIImage imageNamed:@"chatBar_colorMore_video"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
//    
//    UIImage * loc = [[UIImage imageNamed:@"chatBar_colorMore_location"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
//    
//    UIImage * voiceCall = [[UIImage imageNamed:@"chatBar_colorMore_audioCall"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
//    
//    UIImage * videoCall = [[UIImage imageNamed:@"chatBar_colorMore_videoCall"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
//    NSArray * ImageArr = @[photo,camera,video,loc,voiceCall,videoCall];
    NSArray *ImageArr = @[photo,camera];
    for (int i = 0; i < ImageArr.count; i++) {
        
        NSInteger section = i/3;
        
        NSInteger index = i%3;
        
        CGFloat w = [UIScreen mainScreen].bounds.size.width;
        
        CGFloat width = w/3;
        
        CGFloat height = width;
        
        CGFloat Y = section * width;
        
        CGFloat X = index * width;
        
        UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
        CGRect frame = CGRectMake(X, Y, width, height);
        button.frame = frame;
        
        UIImage * image = ImageArr[i];
        [button setImage:image forState:UIControlStateNormal];
        
        [button addTarget:self action:@selector(tapButtonItem:) forControlEvents:UIControlEventTouchUpInside];
        button.tag = i;
        
        [self addSubview:button];

    }

}


-(void)tapButtonItem:(UIButton *)button{
    
    if ([self.delegate respondsToSelector:@selector(functionKeyBoard:DidTapButtonIndex:)]) {
        
        [self.delegate functionKeyBoard:self DidTapButtonIndex:button.tag];
        
    }

}

@end
